package com.sx.pipeline.custom.dialog;

import android.content.Context;
import android.view.View;

import androidx.annotation.NonNull;

import com.alibaba.android.arouter.launcher.ARouter;
import com.lxj.xpopup.core.BottomPopupView;
import com.sx.pipeline.R;
import com.sx.pipeline.arouth.RoutePath;
import com.sx.pipeline.listener.PasswordInputListener;
import com.sx.pipeline.view.OnPasswordInputFinish;
import com.sx.pipeline.view.PasswordView;

/**
 * author : zhouyouqiang
 * e-mail : 1638473898@qq.com
 * date   : 2022/4/12 13:57
 * desc   : 密码输入弹窗
 * version: 1.0
 */
public class DialogPasswordInput extends BottomPopupView {

    private PasswordView passwordView;
    private String strMoney;

    public DialogPasswordInput(@NonNull Context context,String money) {
        super(context);
        this.strMoney=money;
    }

    @Override
    protected int getImplLayoutId() {
        return R.layout.dialog_password;
    }

    @Override
    protected void onCreate() {
        super.onCreate();
        passwordView = findViewById(R.id.password_toggle);
        initListener();
    }

    private void initListener() {
        //添加密码输入完成的响应
        passwordView.setOnFinishInput(new OnPasswordInputFinish() {
            @Override
            public void inputFinish() {
                if (passwordInputListener != null) {
                    passwordInputListener.onInputFinish(passwordView.getStrPassword());
                }
                dismiss();
            }
        });

        passwordView.setMoney(strMoney);


        //退出支付
        passwordView.getCancelImageView().setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                dismiss();
            }
        });

        //忘记密码
        passwordView.getForgetTextView().setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                ARouter.getInstance().build(RoutePath.Setting.MODIFY_LOGIN_PASS).withInt("type",1).navigation();
                dismiss();
            }
        });
    }

    private PasswordInputListener passwordInputListener;

    public DialogPasswordInput setPassInputListener(PasswordInputListener passwordInputListener) {
        this.passwordInputListener = passwordInputListener;
        return this;
    }
}

